<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Log;

class PictureInfo extends Model
{   
	 /**
      * The database table used by the model.
      *
      * @var string
      */
     
     protected $table = 'picture';
     
	/**
	  * The primary key used by the model.	
	  *	
	  *@var string
    */
    protected $primaryKey = 'id';

    /**
     * Each patient case has multiple pictures 
     * 
     * @return patient case instance
     */
     /*
    public function case()
    {
        return $this->belongsTo('App\PatientCase');
    }
*/
    public static function cover($case_id){	
		$cover_url = self::select('pic_url')->where('case_id',$case_id)->first();
	
		$cover_url = $cover_url["pic_url"];
		
		if(is_null($cover_url)){
			$cover_url = asset('/img/logo MW(R).png');
		}
		
		return asset($cover_url);
	}
}
